#include <GL/glut.h>
#include <math.h>

const GLfloat factor = 0.1f;

void myDisplay() {
	GLfloat x;

	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_LINES);
		glVertex2f(-1.0f, 0.0f);
		glVertex2f(1.0f, 0.0f); // X轴
		glVertex2f(0.0f, -1.0f);
		glVertex2f(0.0f, 1.0f); // Y轴
	glEnd();
	
	glBegin(GL_LINE_STRIP);
		for(x=-1.0f/factor; x<1.0f/factor; x+=0.01f)
			glVertex2f(x*factor, sin(x)*factor);
	glEnd();

	glFlush();
} 

int main(int argc, char * argv[]) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
	glutInitWindowPosition(500, 500);
	glutInitWindowSize(500, 500);
	glutCreateWindow("OpenGL Program 5: Sin Function");

	glutDisplayFunc(myDisplay);

	glutMainLoop();

	return 0;
}
